package com.lmk.t03;

import java.io.*;
import java.util.Scanner;

public class PersonTest {
   /* public static void main(String[] args) {

        String path="d:/11/p";
        File file=new File(path);
        try(ObjectInputStream ois=new ObjectInputStream(new FileInputStream(file))) {
           Object o=ois.readObject();
           Person person= (Person) o;
            System.out.println("姓名"+ person.getName());
            System.out.println("年龄"+ person.getAge());


        }catch (Exception e){
            e.printStackTrace();
        }
    }*/



    public static void main2(String[] args) {

        Scanner sc=new Scanner(System.in);
        System.out.println("请输入姓名");
        String str=sc.next();
        System.out.println("请输入年龄");
        int age=sc.nextInt();
        Person person=new Person(str,age);
        String path="d:/11/p";
        File file=new File(path);
        try( ObjectOutputStream oos=new ObjectOutputStream(new FileOutputStream(file))){
            oos.writeObject(person);
            oos.flush();
        }catch (Exception e){
            e.printStackTrace();
        }



    }
}
